a=[]
for i in range(100,1000):
    for y in range(2,i):
        if i%y==0:
            break
    else:
        a.append(i)
n=0
n1=0
n2=0
s0="zero"
s1="one"
s2="two"
s3="three"
s4="four"
s5="five"
s6="six"
s7="seven"
s8="eight"
s9="nine"
s=input().split()
c="";
for i in range(len(s)):
    if s[i]==s0:
        c=c+"0"
    if s[i]==s1:
        c=c+"1"
    if s[i]==s2: 
        c=c+"2"
    if s[i]==s3:
        c=c+"3"
    if s[i]==s4:
        c=c+"4"
    if s[i]==s5:
        c=c+"5"
    if s[i]==s6:
        c=c+"6"
    if s[i]==s7:
        c=c+"7"
    if s[i]==s8:
        c=c+"8"
    if s[i]==s9:
        c=c+"9"
if c!="":
    n=int(c)
if n==0 or n<=99 or n>=1000:
    print("Wrong input")
else:
    if n > 997:
        print("997")
    else:
        if n in a:
            print(n)
        else:
            for i in range(len(a)):
                if a[i]>n:
                    n1=i
                if a[i]<n:
                    n2=i
            if abs(a[n2]-n)>abs(a[n2+1]-n):
                print(a[n2+1])
            else:
                print(a[n2])
